﻿Imports System.Data.SqlClient

Public Class frmThucDon
    Dim dg As New Integer
    Dim da As New DataProvider

    Private Sub frmThucDon_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadCombobox()
        da.OpenConnect()
        Dim cmd As New SqlCommand("select * from THUCDON", da.con)
        Dim dr As SqlDataReader = cmd.ExecuteReader()
        While dr.Read()
            Dim item As New ListViewItem(dr("TenMonAn").ToString())
            item.SubItems.Add(dr("DonGia").ToString())
            item.Name = dr("MaMonAn").ToString()
            lstDanhSachMonAn.Items.Add(item)

        End While

    End Sub
    Public Sub LoadCombobox()
        da = New DataProvider
        Dim dt As New DataTable
        da.OpenConnect()
        cbxLoai.DataSource = da.ShowData("select * from LOAIMONAN")
        cbxLoai.DisplayMember = "TenLoaiMonAn"
        cbxLoai.ValueMember = "MaLoaiMonAn"
    End Sub

    Private Sub btnDong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDong.Click
        Close()
    End Sub

    Private Sub rbTheoLoai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbTheoLoai.CheckedChanged
        cbxLoai.Enabled = True
    End Sub

    Private Sub rbTatCa_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbTatCa.CheckedChanged
        cbxLoai.Enabled = False
    End Sub

    Private Sub lstDanhSachMonAn_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstDanhSachMonAn.MouseDoubleClick
        frmSoLuongMonAn.lbTenMonAn.Text = lstDanhSachMonAn.SelectedItems(0).Text
        frmSoLuongMonAn.dg = lstDanhSachMonAn.SelectedItems(0).SubItems(1).Text
        frmSoLuongMonAn.Show()
        'frmQuanLyThuNgan.lstTTSanPham.Items = lstDanhSachMonAn.SelectedItems(0)

    End Sub

    Private Sub btnChon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChon.Click
        frmSoLuongMonAn.lbTenMonAn.Text = lstDanhSachMonAn.SelectedItems(0).Text
        frmSoLuongMonAn.dg = lstDanhSachMonAn.SelectedItems(0).SubItems(1).Text
        frmSoLuongMonAn.Show()
    End Sub
End Class